package com.study.controller;

import com.study.model.dto.ImageVerifyCodeRespDto;
import com.study.model.dto.request.SendVerifyCodeDto;
import com.study.service.ImageVerifyCodeService;
import com.study.service.SendSmsService;
import com.study.util.result.ApiResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/common")
public class CommonController {

    @Autowired
    private SendSmsService smsService;

    @Autowired
    private ImageVerifyCodeService imageVerifyCodeService;

    @PostMapping("/verify_code")
    public ApiResult sendVerifyCode(@RequestBody SendVerifyCodeDto sendVerifyCodeDto) {
        smsService.sendVerifyCode(sendVerifyCodeDto);
        return ApiResult.SUCCESS();
    }

    @PostMapping("/verify_code_image")
    public ApiResult getVerifyCodeImage(){
        ImageVerifyCodeRespDto imageVerifyCodeRespDto = imageVerifyCodeService.generatorImage();
        return ApiResult.SUCCESS(imageVerifyCodeRespDto);
    }
}
